<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

<title>module Roled::Core - Roled</title>

<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
</script>

<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>


<body id="top" class="module">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="../index.html">Home</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>lib/roled/core.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    
    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-i-authorize_user-21">#authorize_user!</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="../README_rdoc.html">README</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="../Roled.html">Roled</a>
  
    <li><a href="../Roled/Aco.html">Roled::Aco</a>
  
    <li><a href="../Roled/AcosAro.html">Roled::AcosAro</a>
  
    <li><a href="../Roled/ActsAs.html">Roled::ActsAs</a>
  
    <li><a href="../Roled/ActsAs/ClassMethods.html">Roled::ActsAs::ClassMethods</a>
  
    <li><a href="../Roled/Aro.html">Roled::Aro</a>
  
    <li><a href="../Roled/Core.html">Roled::Core</a>
  
    <li><a href="../Roled/Generators.html">Roled::Generators</a>
  
    <li><a href="../Roled/Generators/InstallGenerator.html">Roled::Generators::InstallGenerator</a>
  
    <li><a href="../Roled/RakeTasks.html">Roled::RakeTasks</a>
  
    <li><a href="../Roled/RakeTasks/RakeTasks.html">Roled::RakeTasks::RakeTasks</a>
  
    <li><a href="../InstallRoled.html">InstallRoled</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="module">module Roled::Core</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-authorize_user-21" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">authorize_user!</span><span
            class="method-args">(user, options = {})</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="authorize_user-21-source">
            <pre><span class="ruby-comment"># File lib/roled/core.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">authorize_user!</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">options</span> = {})
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:skip_module</span>])
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:controller</span>] <span class="ruby-operator">=~</span> <span class="ruby-node">%r#{options[:skip_module]}\/\.*/</span>
      <span class="ruby-keyword">return</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span>(<span class="ruby-operator">!</span><span class="ruby-identifier">user</span>.<span class="ruby-identifier">blank?</span>)
    <span class="ruby-identifier">action</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:action</span>]
    <span class="ruby-keyword">if</span>(<span class="ruby-operator">!</span><span class="ruby-identifier">action</span>)
      <span class="ruby-identifier">action</span> = <span class="ruby-string">&quot;index&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">request</span> = <span class="ruby-identifier">user</span>.<span class="ruby-identifier">has_permission_to?</span> <span class="ruby-identifier">params</span>[<span class="ruby-value">:controller</span>], <span class="ruby-identifier">action</span>
    <span class="ruby-keyword">if</span>(<span class="ruby-identifier">request</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">request</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">root_url</span>, <span class="ruby-value">:flash</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-value">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;Unauthorized&quot;</span>}
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- authorize_user-21-source -->
          
        </div>

        

        
      </div><!-- authorize_user-21-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

